<template>
  <!-- 计量单位定义 -->
  <div>
    <!-- <TopFilter :list="topFilterList" :cols="3" :collapse="false" @filterChange="handleFilterChange"></TopFilter> -->
    <FilterTable
      ref="table"
      :columns="tableColumns"
      columnsRef="partPartInfoManageUnitDefinedIndex"
      :fetchapi="fetchapi"
      :params="fetchParams"
      :datakey="'rows'"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.tableColumns = columns)"
    ></FilterTable>
  </div>
</template>

<script>
import { queryPartUnitDefinedList } from '@/api/part/partInfoManage/unitDefined';

export default {
  data() {
    return {
      tableColumns: this.createTableColumns(),
      topFilterList: this.createTopFilterList(),
      fetchapi: queryPartUnitDefinedList,
      fetchParams: { xhrAbort: false }
    };
  },
  methods: {
    createTableColumns() {
      return [
        // {
        //   title: '操作',
        //   dataIndex: 'operate',
        //   render: params => {
        //     return <el-button type="text">编辑</el-button>
        //   }
        // },
        {
          title: '计量单位名称',
          dataIndex: 'UNIT_NAME'
        },
        {
          title: '计量单位代码',
          dataIndex: 'UNIT_CODE'
        }
      ];
    },
    createTopFilterList() {
      return [
        {
          type: 'INPUT',
          label: '计量单位名称',
          fieldName: 'unitName'
        }
      ];
    },
    // 点击搜索或者重置
    handleFilterChange(e) {
      this.fetchParams.xhrAbort = true;
      this.fetchParams = Object.assign(this.fetchParams, {
        ...e,
        xhrAbort: false
      });
    }
  }
};
</script>
